//Copyrighted by Bassoe
var status = 0;
var prize = 10;
 
function start() {
	status = -1;
	action(1, 0, 0);
}

function action(mode, type, selection) {
	if (mode == -1) {
		cm.dispose();
	} else {
		if (mode == 0) {
			cm.sendOk("Well, see you later");
			cm.dispose();
			return;
		}
		if (mode == 1)
			status++;
		else
			status--;
		if (status == 0) {
			cm.sendSimple("Hey there, Have you heard about #rClones#k?\r\nThey not only look cool, but will also help you attack!\r\nI can give you a clone!\r\n\r\n#L1##bWohoo, i want a clone! - " + prize + " Golden Boxes#k#l\r\n#L2##rI want nothing..#k#l");
		} else if (status == 1) {
			if (selection == 1) {
				if (cm.itemQuantity(4280000) >= prize) {
					cm.sendYesNo("Are you sure you want to pay " + prize + " Golden Boxes for a clone?\r\nIt will disappear if you log out.");
				} else {
					cm.sendOk("You don't have " + prize + " Golden Boxes.");
					cm.dispose();
				}
			} else {
				cm.sendOk("Don't bother me..");
				cm.dispose();
			}
		} else if (status == 2) {
			cm.sendGetText("What should be the name of your clone?");
		} else {
			if (cm.getText().length() > 12) {
				cm.sendOk("12 is the maximum length of the name");
			} else {
				cm.gainItem(4280000, -prize);
				cm.giveClone(cm.getText());
				cm.sendOk("Enjoy!");
			}
			cm.dispose();
		}
	}
}
